package com.springark.ms.sampleorders.api;

import com.springark.ms.commons.MsApiResult;
import com.springark.ms.commons.consts.SpringarkContentTypes;
import com.springark.ms.commons.consts.SpringarkRequestHeaders;
import com.springark.ms.sampleorders.service.OrdersService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author hankchan
 * @since 2019/5/10
 */
@RestController
@Validated
public class OrdersAPIs {

    @Resource
    private OrdersService ordersService;

    @GetMapping(value = "/orders/get", produces = SpringarkContentTypes.APPLICATION_JSON)
    public MsApiResult get(@RequestHeader(
            value = SpringarkRequestHeaders.REQUEST_ID, required = false) String requestId) {
        return MsApiResult.newInstance().success(ordersService.get(requestId), requestId);
    }
}
